﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using MODEL;

namespace StudentManage
{
    public partial class Frm_Par_Update : Form
    {
        public Frm_Par_Update()
        {
            InitializeComponent();
        }
        DataGridView dgv1;
        public Frm_Par_Update(DataGridView dgv1)
        {
            this.dgv1 = dgv1;
            InitializeComponent();
        }

        private void Frm_Par_Update_Load(object sender, EventArgs e)
        {
            dgv1.DataSource = BLL.ParameterManage.ChaXunParameter();

            //为控件赋值
            label2.Text = dgv1.SelectedRows[0].Cells["P_sign"].Value.ToString();
            dateTimePicker1.Text= dgv1.SelectedRows[0].Cells["P_Time1"].Value.ToString();
            dateTimePicker2.Text = dgv1.SelectedRows[0].Cells["P_Time2"].Value.ToString();

        }

        private void button1_Click(object sender, EventArgs e)
        {
            Parameter parameter = new Parameter();
            parameter.P_sign = label2.Text;
            parameter.P_Time1 = dateTimePicker1.Text;
            parameter.P_Time2 = dateTimePicker2.Text;
            try
            {
             //执行修改方法
            int num = BLL.ParameterManage.ParameterUpdate(parameter);
            if (num>0)
            {
                MessageBox.Show("操作成功");
                dgv1.DataSource = BLL.ParameterManage.ChaXunParameter();
                
            }
            else 
            {
                MessageBox.Show("操作失败");
            }

            }
            catch (Exception ex)
            {
                //显示错误信息
                MessageBox.Show(ex.Message);
                //Frm_List.listBox1.Items.Add("执行操作时出现问题:\t\n" + ex.Message);
            }


        }
    }
}
